<template>
    <Tabbar v-model="active">
        <TabbarItem icon="home-o">首页</TabbarItem>
        <TabbarItem to="/gouwuche" icon="shopping-cart-o" :badge="num">购物车</TabbarItem>
        <TabbarItem to="/user" icon="contact">我的</TabbarItem>
    </Tabbar>
</template>

<script setup lang="ts">

import { Tabbar, TabbarItem } from 'vant';

import { ref, onMounted } from 'vue';

import { gouwuche } from '@/api';

const active = ref(0)

const num = ref()

onMounted(async () => {
    const id = localStorage.getItem('userid') as string
    // console.log(id);
    const result = await gouwuche(id);
    // console.log(result.data.data.length);
    num.value = result.data.data.length

   
})

</script>

<style scoped>

</style>